package service.impl;

import dao.CommentDao;
import dao.impl.CommentDaoImpl;
import pojo.Comments;
import service.CommentsService;

import java.sql.SQLException;
import java.util.ArrayList;

public class CommentsServiceImpl implements CommentsService {
    CommentDao commentDao = new CommentDaoImpl();
    private boolean flag = false;


    public ArrayList<Comments> findCommentByNid(Integer nid) throws SQLException, ClassNotFoundException {
        ArrayList<Comments> commentList = new ArrayList<>();
        commentList = commentDao.findCommentByNid(nid);
        return commentList;

    }


    public boolean addComment1(Comments comments) throws SQLException {
        flag = commentDao.addComment1(comments);
        return flag;
    }


    public boolean userDeleteComment(Integer cid) throws SQLException {
        flag = commentDao.userDeleteComment(cid);
        return flag;
    }


    public Comments findCommentByCid(Integer cid) throws SQLException, ClassNotFoundException {
        Comments comments = new Comments();
        comments = commentDao.findCommentByCid(cid);
        return comments;
    }
}
